home *** CD-ROM | disk | FTP | other *** search
- Path: wagner.spc.videotron.ca!news
- From: bibcegep@granby.mtl.net (Daniel Marquis)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: getch() equivalency help ...
- Date: Mon, 22 Jan 1996 17:45:01 GMT
- Organization: SPC
- Message-ID: <4e0f3j$9cm@wagner.spc.videotron.ca>
- References: <4dpe6p$e4j@twin.wasatch.com>
- Reply-To: bibcegep@granby.mtl.net
- NNTP-Posting-Host: ttyc1.granby.mtl.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- >I am looking for help with the following question/problem:
-
- >I want to have a function that does the same thing as getch() from
- >conio.h, but without needing to include conio.h.
-
- >This is for a program that will be compiled across about 5 different
- >platforms, and the only one that supports conio.h is MS-DOS.
-
- >I know a similar function is available in UNIX with the ncurses library,
- >but I don't have that on my UNIX box ...
-
- >I need a way to do what getch() does, i.e. pause and wait for a SINGLE
- >KEYSTROKE and then pass the value of the pressed key back to the calling
- >function.
-
- >For example:
-
- > char incoming=getch();
-
- >will pause the program until a single key is pressed and feed the value of
- >that key to the char variable incoming.
-
- >I would most optimally like to be able to do this using only what's in
- >iostream.h or stdio.h, whose functions and operators behave alike across all
- >of my target platforms.
-
- >I have tried the following:
-
- > char incoming=cin.get();
-
- >This pauses the program, but allows an entire line to be entered, terminated
- >by a newline, and then only the first character of the line is fed to
- >incoming, and the rest of the line is available to the next input operation
- >on the input stream.
-
- >The other version of cin.get() does the same thing:
- >
- > cin.get(incoming);
-
- >I have tried other functions from stdio.h that have the same result as above.
-
- > char incoming=getchar();
- > char incoming=fgetc(stdin);
-
- >I can't seem to find a way to get just a single keystroke in and then flush
- >the buffer ...
-
- >The only way I have been able to get the behaviour I want is with getch(), and
- >it isn't supported on the other target platforms.
-
- >If anyone can help, I thank you in advance.
-
- >RichD
- >rdemanow@wasatch.com
- >rjd9404@wcslc.edu
-
- >--
- >rdemanow@wasatch.com |I am lost. I have gone to look for
- > |myself.
- >press any key to continue ... |If I should return before I get back,
- >press any other key to quit ...|please ask me to wait here.
- I don't really know how in C but you can do it by calling the good
- interrupt. I dont remember the number... I you don't know witch and
- how reply at martinclaude@citenet.net or mclaude@citenet.net (I'm
- changing my address soon...)
-
-
-
-